#pragma once

#include <sys_def.h>

static inline void wreg(u32_s reg_q, u32_s value) {
	volatile u32_s* reg_p = (volatile u32_s*)reg_q;
	*reg_p = value;
}

static inline void wreg_u8(u32_s reg_q, u32_s value) {
	volatile u8_s* reg_p = (volatile u8_s*)reg_q;
	*reg_p = value;
}

static inline void wreg_u16(u32_s reg_q, u32_s value) {
	volatile u16_s* reg_p = (volatile u16_s*)reg_q;
	*reg_p = value;
}

static inline u32_s rreg(u32_s reg_q) {
	const volatile u32_s* reg_p = (const volatile u32_s*)reg_q;
	return *reg_p;
}

static inline u32_s rreg_u8(u32_s reg_q) {
	const volatile u8_s* reg_p = (const volatile u8_s*)reg_q;
	return *reg_p;
}

static inline u32_s rreg_u16(u32_s reg_q) {
	const volatile u16_s* reg_p = (const volatile u16_s*)reg_q;
	return *reg_p;
}

static inline i32_s rreg_i8(u32_s reg_q) {
	const volatile i8_s* reg_p = (const volatile i8_s*)reg_q;
	return *reg_p;
}

static inline i32_s rreg_i16(u32_s reg_q) {
	const volatile i16_s* reg_p = (const volatile i16_s*)reg_q;
	return *reg_p;
}
